<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Siam_keuangan_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
    }

    function getNeraca($nim)
    {
        $query = "SELECT * FROM view_data_neraca WHERE `NIM`='$nim' AND `STATUS`!='1' ORDER BY `NAMA_TAHUN`";
        $query = $this->db->query($query);

        if($query->num_rows()>0)
          $data = $query->result();
        else
          $data = NULL;

        return $data;
     }

     function getNeracaDistinct($nim)
     {
        $query = "SELECT * FROM view_data_neraca WHERE `NIM`='$nim' AND `STATUS`!='1' GROUP BY KODE_TAGIHAN, KODE_TAHUN, KODE_SEMESTER ORDER BY `NAMA_TAHUN`";
        $query = $this->db->query($query);

        if($query->num_rows()>0)
          $data = $query->result();
        else
          $data = NULL;

        return $data;
     }

     function detailTagihanAngsuran($nim, $tagihan, $tahun, $semester)
     {
        $query = "SELECT * FROM view_data_neraca WHERE `NIM`='$nim' AND `STATUS`!='1' AND KODE_TAGIHAN=$tagihan AND KODE_TAHUN='$tahun' AND KODE_SEMESTER=$semester";
        $query = $this->db->query($query);

        if($query->num_rows()>0)
          $data = $query->result();
        else
          $data = NULL;

        return $data;
     }

     function detailPotonganAngsuran($nim, $tagihan, $tahun, $semester)
     {
        $query = "SELECT * FROM potongan WHERE `NIM`='$nim' AND ID_TAGIHAN=$tagihan AND TAHUN='$tahun' AND SEMESTER=$semester";
        $query = $this->db->query($query);

        if($query->num_rows()>0)
          $data = $query->result();
        else
          $data = NULL;

        return $data;
     }
}

